erDiagram
    user {
        BIGINT user_id PK
        VARCHAR username
        VARCHAR password
        VARCHAR name
        VARCHAR gender
        INT age
        VARCHAR phone
        VARCHAR id_card
        DATETIME create_time
        DATETIME update_time
    }
    admin {
        BIGINT admin_id PK
        VARCHAR username
        VARCHAR password
        VARCHAR name
        VARCHAR phone
        DATETIME create_time
    }
    department {
        BIGINT department_id PK
        VARCHAR department_name
        VARCHAR description
    }
    position {
        BIGINT position_id PK
        VARCHAR position_name
    }
    doctor {
        BIGINT doctor_id PK
        VARCHAR name
        VARCHAR gender
        VARCHAR phone
        BIGINT department_id FK
        BIGINT position_id FK
        VARCHAR intro
        DATETIME create_time
    }
    indicator_category {
        BIGINT category_id PK   
        VARCHAR category_name
    }
    examination_indicator {
        BIGINT indicator_id PK
        VARCHAR indicator_code
        VARCHAR indicator_name
        BIGINT category_id FK
        DOUBLE lower_limit
        DOUBLE upper_limit
        DOUBLE price
        VARCHAR description
    }
    package {
        BIGINT package_id PK
        VARCHAR package_name
        VARCHAR description
        DOUBLE total_price
        DATETIME create_time
    }
    package_item {
        BIGINT id PK
        BIGINT package_id FK
        BIGINT indicator_id FK
    }
    doctor_schedule {
        BIGINT schedule_id PK
        BIGINT doctor_id FK
        DATE schedule_date
        VARCHAR time_period
        INT status
    }
    examination_order {
        BIGINT order_id PK
        BIGINT user_id FK
        BIGINT doctor_id FK
        BIGINT package_id FK
        BIGINT indicator_id FK
        VARCHAR order_type
        DATE order_date
        INT status
        VARCHAR remark
        DATETIME create_time
    }
    sample {
        BIGINT sample_id PK
        BIGINT order_id FK
        VARCHAR sample_type
        DATETIME collection_time
        INT status
        VARCHAR remark
        DATETIME create_time
    }
    indicator_result {
        BIGINT result_id PK
        BIGINT sample_id FK
        BIGINT indicator_id FK
        VARCHAR result_value
        TINYINT abnormal_flag
        VARCHAR doctor_comment
        DATETIME create_time
    }

    department ||--o{ doctor : has
    position ||--o{ doctor : has
    user ||--o{ examination_order : places
    doctor ||--o{ doctor_schedule : schedules
    doctor ||--o{ examination_order : assigned
    indicator_category ||--o{ examination_indicator : categorizes
    package ||--o{ package_item : contains
    examination_indicator ||--o{ package_item : includes
    package ||--o{ examination_order : selected
    examination_indicator ||--o{ examination_order : selected
    examination_order ||--o{ sample : has
    sample ||--o{ indicator_result : has
    examination_indicator ||--o{ indicator_result : measures